300ff794dfd6e5df1540abada309aaa6c8bc74e6,src/org/pentaho/di/pan/Pan.java,Pan,main,#String[]#,47
Before Change
log.logDebug("Pan", "Parsing command line options.");
if (!Const.isEmpty(optionRepname) && !"Y".equalsIgnoreCase(optionNorep.toString()))
{
log.logDebug("Pan", "Loading available repositories.");
RepositoriesMeta repsinfo = new RepositoriesMeta(log);
if (repsinfo.readData())
{
log.logDebug("Pan", "Finding repository ["+optionRepname+"]");
repinfo = repsinfo.findRepository(optionRepname.toString());
if (repinfo!=null)
{
// Define and connect to the repository...
log.logDebug("Pan", "Allocate & connect to repository.");
Repository rep = new Repository(log, repinfo, userinfo);
if (rep.connect("Pan commandline"))
{
RepositoryDirectory directory = rep.getDirectoryTree(); // Default = root
// Find the directory name if one is specified...
if (!Const.isEmpty(optionDirname))
{
directory = rep.getDirectoryTree().findDirectory(optionDirname.toString());
}
if (directory!=null)
{
// Check username, password
log.logDebug("Pan", "Check supplied username and password.");
userinfo = new UserInfo(rep, optionUsername.toString(), optionPassword.toString());
if (userinfo.getID()>0)
{
// Load a transformation
if (!Const.isEmpty(optionTransname))
{
log.logDebug("Pan", "Load the transformation info...");
transMeta = new TransMeta(rep, optionTransname.toString(), directory);
log.logDebug("Pan", "Allocate transformation...");
trans = new Trans(transMeta);
trans.setRepository(rep);
}
else
// List the transformations in the repository
if ("Y".equalsIgnoreCase(optionListtrans.toString()))
{
log.logDebug("Pan", "Getting list of transformations in directory: "+directory);
String transnames[] = rep.getTransformationNames(directory.getID());
for (int i=0;i<transnames.length;i++)
{
System.out.println(transnames[i]);
}
}
else
// List the directories in the repository
if ("Y".equalsIgnoreCase(optionListdir.toString()))
{
String dirnames[] = rep.getDirectoryNames(directory.getID());
for (int i=0;i<dirnames.length;i++)
{
System.out.println(dirnames[i]);
}
}
else
// Export the repository
if (!Const.isEmpty(optionExprep))
{
System.out.println("Exporting all objects in the repository to file ["+optionExprep+"]");
rep.exportAllObjects(null, optionExprep.toString(), directory);
System.out.println("Finished exporting all objects in the repository to file ["+optionExprep+"]");
}
else
{
System.out.println("ERROR: No transformation name supplied: which one should be run?");
}
}
else
{
System.out.println("ERROR: Can't verify username and password.");
userinfo=null;
repinfo=null;
}
}
else
{
System.out.println("ERROR: Can't find the specified directory ["+optionDirname+"]");
userinfo=null;
repinfo=null;
}
rep.disconnect();
}
else
{
System.out.println("ERROR: Can't connect to the repository.");
}
}
else
{
System.out.println("ERROR: No repository provided, can't load transformation.");
}
}
else
{
System.out.println("ERROR: No repositories defined on this system.");
}
}
// Try to load the transformation from file, even if it failed to load from the repository
// You could implement some fail-over mechanism this way.
//
if (trans==null && !Const.isEmpty(optionFilename))
{
log.logDetailed("Pan", "Loading transformation from XML file ["+optionFilename+"]");
transMeta = new TransMeta(optionFilename.toString());
trans = new Trans(transMeta);
}
// Try to load the transformation from a jar file
//
if (trans==null && !Const.isEmpty(optionJarFilename))
{
try
{
log.logDetailed("Pan", "Loading transformation from jar file ["+optionJarFilename+"]");
InputStream inputStream = Pan.class.getResourceAsStream(optionJarFilename.toString());
StringBuffer xml = new StringBuffer();
int c;
while ((c=inputStream.read()) != -1) xml.append((char)c);
inputStream.close();
Document document = XMLHandler.loadXMLString(xml.toString());
transMeta = new TransMeta(XMLHandler.getSubNode(document, "transformation"), null);
trans = new Trans(transMeta);
}
catch(Exception e)
{
System.out.println("Error reading jarfile: "+e.toString());
System.out.println(Const.getStackTracker(e));
throw e;
}
}
}
if ("Y".equalsIgnoreCase(optionListrep.toString()))
{
log.logDebug("Pan", "Getting the list of repositories...");
RepositoriesMeta ri = new RepositoriesMeta(log);
if (ri.readData())
{
After Change
if(log.isDebug()) log.logDebug("Pan", "Parsing command line options.");
if (!Const.isEmpty(optionRepname) && !"Y".equalsIgnoreCase(optionNorep.toString()))
{
if(log.isDebug()) log.logDebug("Pan", "Loading available repositories.");
RepositoriesMeta repsinfo = new RepositoriesMeta(log);
if (repsinfo.readData())
{
if(log.isDebug()) log.logDebug("Pan", "Finding repository ["+optionRepname+"]");
repinfo = repsinfo.findRepository(optionRepname.toString());
if (repinfo!=null)
{
// Define and connect to the repository...
if(log.isDebug()) log.logDebug("Pan", "Allocate & connect to repository.");
Repository rep = new Repository(log, repinfo, userinfo);
if (rep.connect("Pan commandline"))
{
RepositoryDirectory directory = rep.getDirectoryTree(); // Default = root
// Find the directory name if one is specified...
if (!Const.isEmpty(optionDirname))
{
directory = rep.getDirectoryTree().findDirectory(optionDirname.toString());
}
if (directory!=null)
{
// Check username, password
if(log.isDebug()) log.logDebug("Pan", "Check supplied username and password.");
userinfo = new UserInfo(rep, optionUsername.toString(), optionPassword.toString());
if (userinfo.getID()>0)
{
// Load a transformation
if (!Const.isEmpty(optionTransname))
{
if(log.isDebug()) log.logDebug("Pan", "Load the transformation info...");
transMeta = new TransMeta(rep, optionTransname.toString(), directory);
if(log.isDebug()) log.logDebug("Pan", "Allocate transformation...");
trans = new Trans(transMeta);
trans.setRepository(rep);
}
else
// List the transformations in the repository
if ("Y".equalsIgnoreCase(optionListtrans.toString()))
{
if(log.isDebug()) log.logDebug("Pan", "Getting list of transformations in directory: "+directory);
String transnames[] = rep.getTransformationNames(directory.getID());
for (int i=0;i<transnames.length;i++)
{
System.out.println(transnames[i]);
}
}
else
// List the directories in the repository
if ("Y".equalsIgnoreCase(optionListdir.toString()))
{
String dirnames[] = rep.getDirectoryNames(directory.getID());
for (int i=0;i<dirnames.length;i++)
{
System.out.println(dirnames[i]);
}
}
else
// Export the repository
if (!Const.isEmpty(optionExprep))
{
System.out.println("Exporting all objects in the repository to file ["+optionExprep+"]");
rep.exportAllObjects(null, optionExprep.toString(), directory);
System.out.println("Finished exporting all objects in the repository to file ["+optionExprep+"]");
}
else
{
System.out.println("ERROR: No transformation name supplied: which one should be run?");
}
}
else
{
System.out.println("ERROR: Can't verify username and password.");
userinfo=null;
repinfo=null;
}
}
else
{
System.out.println("ERROR: Can't find the specified directory ["+optionDirname+"]");
userinfo=null;
repinfo=null;
}
rep.disconnect();
}
else
{
System.out.println("ERROR: Can't connect to the repository.");
}
}
else
{
System.out.println("ERROR: No repository provided, can't load transformation.");
}
}
else
{
System.out.println("ERROR: No repositories defined on this system.");
}
}
// Try to load the transformation from file, even if it failed to load from the repository
// You could implement some fail-over mechanism this way.
//
if (trans==null && !Const.isEmpty(optionFilename))
{
if(log.isDetailed()) log.logDetailed("Pan", "Loading transformation from XML file ["+optionFilename+"]");
transMeta = new TransMeta(optionFilename.toString());
trans = new Trans(transMeta);
}
// Try to load the transformation from a jar file
//
if (trans==null && !Const.isEmpty(optionJarFilename))
{
try
{
if(log.isDetailed()) log.logDetailed("Pan", "Loading transformation from jar file ["+optionJarFilename+"]");
InputStream inputStream = Pan.class.getResourceAsStream(optionJarFilename.toString());
StringBuffer xml = new StringBuffer();
int c;
while ((c=inputStream.read()) != -1) xml.append((char)c);
inputStream.close();
Document document = XMLHandler.loadXMLString(xml.toString());
transMeta = new TransMeta(XMLHandler.getSubNode(document, "transformation"), null);
trans = new Trans(transMeta);
}
catch(Exception e)
{
System.out.println("Error reading jarfile: "+e.toString());
System.out.println(Const.getStackTracker(e));
throw e;
}
}
}
if ("Y".equalsIgnoreCase(optionListrep.toString()))
{
if(log.isDebug()) log.logDebug("Pan", "Getting the list of repositories...");
RepositoriesMeta ri = new RepositoriesMeta(log);
if (ri.readData())
{